﻿using System.Linq;
using AllIsWell.Tests.TestData;
using NUnit.Framework;

namespace AllIsWell.Services.Tests
{
    [TestFixture]
    class DestinyServiceTests : AllIsWellServiceTestBase
    {
        private DestinyService _destinyService;

        [SetUp]
        public void SetUp()
        {
            _destinyService = new DestinyService(UnitOfWorkMock.Object);
        }

        [Test]
        public void ShouldGetAllDestinyFromRepository()
        {
            var expectedDestinies = DestinySeed.GetDestinies(new[] { "Start it Well", "Finish It Strong" }).ToArray();
            DestinyRepositoryMock.Setup(repo => repo.Destinies).Returns(expectedDestinies);

            var actualDestinies = _destinyService.Destinies;

            CollectionAssert.AreEqual(expectedDestinies, actualDestinies);
        }

        [Test]
        public void ShouldGetDestinyMatchingGivenIdFromRepository()
        {
            var expectedDestiny = DestinySeed.GetDestiny(1);
            DestinyRepositoryMock.Setup(repo => repo.GetDestiny(1)).Returns(expectedDestiny);

            var actualDestiny = _destinyService.GetDestiny(1);

            Assert.AreEqual(expectedDestiny, actualDestiny);
        }
    }
}